//
//  BrandShowroom.m
//  DuFeiNi
//
//  Created by beeway10 on 14-3-4.
//  Copyright (c) 2014年 beeway10. All rights reserved.
//

#import "BrandShowroom.h"
#import "videoPage.h"
#import "WQKeyChain.h"
#define CACHES_Document  [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
static NSString *  const KEY_IN_KEYCHAIN =  @" com.wuqian.app.allinfo ";
static NSString *  const KEY_PASSWORD =  @" com.wuqian.app.password ";

@interface BrandShowroom ()

@end

@implementation BrandShowroom

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-( void)savePassWord:(NSDictionary *)password
{
    NSMutableDictionary *usernamepasswordKVPairs = [NSMutableDictionary dictionary];
    [usernamepasswordKVPairs setObject:password forKey:KEY_PASSWORD];
    [WQKeyChain save:KEY_IN_KEYCHAIN data:usernamepasswordKVPairs];
}

-(id)readPassWord
{
    NSMutableDictionary *usernamepasswordKVPair = (NSMutableDictionary *)[WQKeyChain load:KEY_IN_KEYCHAIN];
    return [usernamepasswordKVPair objectForKey:KEY_PASSWORD];
}

-( void)deletePassWord
{
    [WQKeyChain delete:KEY_IN_KEYCHAIN];
}
-(void)GotoBack:(id)sender
{
    videoPage *vv=[[videoPage alloc]init];
    [self.navigationController pushViewController:vv animated:NO];
    //[self.navigationController popViewControllerAnimated:NO];
}



- (void)viewDidLoad
{
    [super viewDidLoad];
 
    NSObject<PLIPanorama> * panorama = nil;
    plView=[[PLView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
  
    [self.view addSubview:plView];
     PLCubicPanorama * cubicPanorama = [PLCubicPanorama panorama];
 
    [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[[NSBundle mainBundle]resourcePath] stringByAppendingString:@"/360-wy1-b.jpg"]]]face:PLCubeFaceOrientationFront];
    
    [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath: [[[NSBundle mainBundle]resourcePath] stringByAppendingString:@"/360-wy1-d.jpg"]]]face:PLCubeFaceOrientationDown];
    
    [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath: [[[NSBundle mainBundle]resourcePath] stringByAppendingString:@"/360-wy1-u.jpg"]]]face:PLCubeFaceOrientationUp];
    
    [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath: [[[NSBundle mainBundle]resourcePath] stringByAppendingString:@"/360-wy1-r.jpg"]]]face:PLCubeFaceOrientationRight];
    
    [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath: [[[NSBundle mainBundle]resourcePath] stringByAppendingString:@"/360-wy1-l.jpg"]]]face:PLCubeFaceOrientationLeft];
    
    [cubicPanorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath: [[[NSBundle mainBundle]resourcePath] stringByAppendingString:@"/360-wy1-f.jpg"]]]face:PLCubeFaceOrientationBack];
    
    panorama = cubicPanorama;
     [plView setPanorama:panorama];
  
    
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    
    NSLog(@"webViewDidStartLoad:(UIWebView *)webView");
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    
    NSLog(@"webViewDidFinishLoad:(UIWebView *)webView");
    
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    NSLog(@"error:%@",error.localizedFailureReason);
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    BOOL isOK=NO;
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft | interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        isOK  = YES;
    }
    return isOK;
}

- (void)transition:(UIView*)view type:(NSString * )type
{
    
    CATransition *animation=[CATransition animation];
    animation.delegate=self;
    animation.duration=0.1;
    
    animation.timingFunction=UIViewAnimationCurveEaseInOut;
    
    animation.type=kCATransitionMoveIn;
    animation.subtype=type;
    [view.layer addAnimation:animation forKey:@"move in"];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
